package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysBroadband;
import com.ruoyi.system.service.ISysBroadbandService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 宽带信息Controller
 * 
 * @author ruoyi
 * @date 2022-03-10
 */
@RestController
@RequestMapping("/system/broadband")
public class SysBroadbandController extends BaseController
{
    @Autowired
    private ISysBroadbandService sysBroadbandService;

    /**
     * 查询宽带信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:broadband:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysBroadband sysBroadband)
    {
        startPage();
        List<SysBroadband> list = sysBroadbandService.selectSysBroadbandList(sysBroadband);
        return getDataTable(list);
    }

    /**
     * 导出宽带信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:broadband:export')")
    @Log(title = "宽带信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysBroadband sysBroadband)
    {
        List<SysBroadband> list = sysBroadbandService.selectSysBroadbandList(sysBroadband);
        ExcelUtil<SysBroadband> util = new ExcelUtil<SysBroadband>(SysBroadband.class);
        util.exportExcel(response, list, "宽带信息数据");
    }

    /**
     * 获取宽带信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:broadband:query')")
    @GetMapping(value = "/{broadbandId}")
    public AjaxResult getInfo(@PathVariable("broadbandId") Long broadbandId)
    {
        return AjaxResult.success(sysBroadbandService.selectSysBroadbandByBroadbandId(broadbandId));
    }

    /**
     * 新增宽带信息
     */
    @PreAuthorize("@ss.hasPermi('system:broadband:add')")
    @Log(title = "宽带信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysBroadband sysBroadband)
    {
        sysBroadband.setCreateBy(getUsername());
        return toAjax(sysBroadbandService.insertSysBroadband(sysBroadband));
    }

    /**
     * 修改宽带信息
     */
    @PreAuthorize("@ss.hasPermi('system:broadband:edit')")
    @Log(title = "宽带信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysBroadband sysBroadband)
    {
        sysBroadband.setUpdateBy(getUsername());
        return toAjax(sysBroadbandService.updateSysBroadband(sysBroadband));
    }

    /**
     * 删除宽带信息
     */
    @PreAuthorize("@ss.hasPermi('system:broadband:remove')")
    @Log(title = "宽带信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{broadbandIds}")
    public AjaxResult remove(@PathVariable Long[] broadbandIds)
    {
        return toAjax(sysBroadbandService.deleteSysBroadbandByBroadbandIds(broadbandIds));
    }
}
